package org.yray.io.file.conf;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2020-2050</p>
 * <p>Company: cfss</p>
 *
 * @author lyg
 * @version 0.0.1
 * @date 2020/9/5 14:11
 * @other 以下修改下及其它信息
 * <p>v0.0.2,lyg,这是示例</p>
 */
@Configuration
public class StaticFilePathConfig implements WebMvcConfigurer {


    @Value("${fgbp.record.accessPath:/data/**}")
    private String accessPath;
    @Value("${fgbp.record.folder:/data/}")
    private String recordFolder;

    @Autowired
    HandlerInterceptor handlerInterceptor;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(accessPath).addResourceLocations("file:" + recordFolder);
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(handlerInterceptor);
    }
}

